﻿using System.Security.Claims;
using IdentityServer4.Extensions;

namespace Demo.Net.IdentityServer.IdentityServer
{

    public static class ProfileServiceExtensions
    {
        public static int GetUserId(this ClaimsPrincipal claims)
        {
            return  int.Parse(  claims.GetSubjectId());
        }

        public static string GetUserName(this ClaimsPrincipal claims)
        {
            return  claims.FindFirst(ClaimTypes.Name)?.Value;
        }


        public static string GetUserRealName(this ClaimsPrincipal claims)
        {
            return claims.FindFirst("realname")?.Value;
        }
    }
}
